import {
  BaseEntity,
  Column,
  CreateDateColumn,
  DeleteDateColumn,
  Entity,
  ManyToOne,
  OneToMany,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';
import { Mercadoproduct } from './mercadoproduct.entity';
import { Box } from './box.entity';

@Entity()
export class Mercadosku extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    comment: '名称',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  name: string;

  @Column({
    comment: '美客多编号',
    nullable: true,
    unique: true,
    default: null,
    type: 'varchar',
  })
  mercadoNumber: string;

  @Column({
    comment: '编号',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  number: string;

  // @Column({
  //   comment: '库存数',
  //   nullable: true,
  //   unique: false,
  //   default: 0,
  //   type: 'int',
  // })
  // stock: number;

  // @Column({
  //   comment: '箱数',
  //   nullable: true,
  //   unique: false,
  //   default: 0,
  //   type: 'int',
  // })
  // boxNumber: number;
  @Column({
    comment: 'sku图',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  image: string;

  @Column({
    comment: '采购价',
    nullable: true,
    unique: false,
    default: 0,
    type: 'decimal',
    precision: 10,
    scale: 2,
  })
  purchasePrice: number;

  @Column({
    comment: '销售价',
    nullable: true,
    unique: false,
    default: 0,
    type: 'decimal',
    precision: 10,
    scale: 2,
  })
  salePrice: number;

  @ManyToOne(
    () => Mercadoproduct,
    (mercadoproduct) => mercadoproduct.mercadoskus,
  )
  mercadoproduct: Mercadoproduct;

  @OneToMany(() => Box, (box) => box.mercadosku)
  boxs: Box[];

  @CreateDateColumn()
  createTime: Date;

  @UpdateDateColumn()
  updateTime: Date;

  @DeleteDateColumn({ nullable: true })
  deleteTime: Date;
}
